package com.JZ.QM.service.impl;

import com.JZ.QM.service.EntrustRecordService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.JZ.QM.common.utils.PageUtils;
import com.JZ.QM.common.utils.Query;

import com.JZ.QM.common.dao.EntrustRecordDao;
import com.JZ.QM.common.entity.EntrustRecordEntity;

import javax.annotation.Resource;


@Service
public class EntrustRecordServiceImpl extends ServiceImpl<EntrustRecordDao, EntrustRecordEntity> implements EntrustRecordService {

    @Resource
    EntrustRecordDao entrustRecordDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) throws Exception {
        IPage<EntrustRecordEntity> page = this.page(
                new Query<EntrustRecordEntity>().getPage(params),
                new QueryWrapper<EntrustRecordEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 通过调仓记录获取委托列表
     * @param adjustId
     * @return
     */
    @Override
    public ArrayList<EntrustRecordEntity> getEntrustRecordListByAdjustId(Long adjustId) {
        //委托记录实体列表
        ArrayList<EntrustRecordEntity> entrustRecordEntityArrayList =  new ArrayList<>();
        QueryWrapper<EntrustRecordEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("record_id",adjustId);

        entrustRecordEntityArrayList = (ArrayList<EntrustRecordEntity>) entrustRecordDao.selectList(queryWrapper);

        return entrustRecordEntityArrayList;
    }

}